﻿package mortal.game.view.heroArena.renderer
{
    import Message.Public.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.heroArena.util.*;

    public class HeroArenaGroupListCellRenderer extends GCellRenderer
    {
        private var _roleName:GTextFiled;
        private var _numInfo:GTextFiled;
        private var _combat:GTextFiled;
        private var _levelCareer:GTextFiled;
        private var _joinBtn:GButton;
        private var _teamData:SArena2v2Team;

        public function HeroArenaGroupListCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._roleName = UIFactory.gTextField("", 15, 8 - 3, 91, 20, this, GlobalStyle.textFormatBai.center());
            this._numInfo = UIFactory.gTextField(Language.getString(41514), 26, 28 - 3, 72, 20, this, GlobalStyle.textFormatBai.center());
            this._combat = UIFactory.gTextField("", 136 + 12 - 5, 16 - 2, 72, 20, this, GlobalStyle.textFormatChen);
            this._levelCareer = UIFactory.gTextField("", 231, 16 - 2, 95, 20, this, GlobalStyle.textFormatChen);
            this._joinBtn = UIFactory.gButton(Language.getString(41515), 348, 14, 43, 22, this);
            this._joinBtn.configEventListener(MouseEvent.CLICK, this.onJoinHandler);
            this.pushUIToDisposeVec(UIFactory.bg(0, 45, 403, 2, this, ImagesConst.SplitLine));
            return;
        }// end function

        private function onJoinHandler(event:MouseEvent) : void
        {
            if (HeroArenaUtil.isTeamFull())
            {
                MsgManager.showRollTipsMsg(Language.getString(41516), MsgRollTipsType.msgRollTips3);
                return;
            }
            GameProxy.copy.joinArenaTeam(this._teamData.teamId);
            MsgManager.showRollTipsMsg(Language.getString(41517));
            this._joinBtn.filters = [FilterConst.colorFilter2];
            this._joinBtn.mouseEnabled = false;
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:String = null;
            super.data = param1;
            this._teamData = param1 as SArena2v2Team;
            if (this._teamData)
            {
                if (this._teamData.captainPlayer)
                {
                    this._roleName.text = this._teamData.captainPlayer.name;
                    this._combat.text = this._teamData.captainPlayer.combat + "";
                    _loc_2 = GameDefConfig.instance.getECareerNameAddColoer(this._teamData.captainPlayer.career);
                    this._levelCareer.htmlText = "Lv." + this._teamData.captainPlayer.level + "·" + _loc_2;
                    this._joinBtn.filters = [];
                    this._joinBtn.mouseEnabled = true;
                }
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._roleName.dispose();
            this._roleName = null;
            this._numInfo.dispose();
            this._numInfo = null;
            this._combat.dispose();
            this._combat = null;
            this._levelCareer.dispose();
            this._levelCareer = null;
            this._joinBtn.dispose();
            this._joinBtn = null;
            this._teamData = null;
            return;
        }// end function

    }
}
